<?php
/*****************
*作者：jeff.liu
*联系方式：13810908686
*电子邮件：ljf1279@yeah.net
******************/
// 抓取远程资源文件

function get_remote_resource($url)
{
	$info = parse_url($url);//http://i3.sinaimg.cn/dy/temp/450/2008/0326/U2251P1T450D15F10119DT20081030093851.jpg
	$url = ereg_replace("[\\\"]",'',$url);
	$file_name = basename($info['path']);
	$arr_path = split("\.",$file_name);
	$file_ext = strtolower($arr_path[count($arr_path)-1]);
	if(!$file_ext)
	{
		$file_ext = 'jpg';
	}
	$content = file_get_contents($url);
	$save_path = '/spider/'.date('Y/m/d/');
	if(!@is_dir(IMG_ROOT.$save_path))
	{
		@mkdir(IMG_ROOT.$save_path,0777,true);// php5 only
	}
	$file_new_name = date('His').rand(100,999).'.'.$file_ext;
	if(file_put_contents(IMG_ROOT.$save_path.$file_new_name,$content))
	{
		return IMG_URL.$save_path.$file_new_name;
	}
	return false;
}
// 不丢失参数拼接分页页号
function get_page_no($pgnm,$pgno)
{
	$q = $_SERVER['QUERY_STRING'];
	parse_str($q,$qs);
	if($pgnm)
	{
	$qs[$pgnm] = $pgno;
	}
	return http_build_query($qs);
}

//发出提示
function alert($message = "", $action = "back", $location = "", $is_alert = true)
{
	global $time_start;
	$message .= '-----mysql:c'.$GLOBALS['db']->get_run_time().'|q'.$GLOBALS['db']->get_query_num().'&php:t'.(microtime(1) - $time_start) .'s';
	$path = dirname(__FILE__);
	$file_foot = $path."/foot.php";
	if($is_alert)
	{
		echo "$message <script>alert(\"$message\");</script>";
	}
	if($action == "location" && $location != '')
	{
		echo "<a href='$location' onclick='location.href=\"$location\";'>返回</a>";
		if($is_alert)
		{
			echo "<script>location.href='$location';</script>";
		}
		include($file_foot);
		exit;
	}
	if($action == "halt")
	{
		include($file_foot);
		exit;
	}
	if($action == "back")
	{
		echo "<a href='".$_SERVER['HTTP_REFERER']."' onclick='history.go(-1);'>返回</a>";
		if($is_alert)
		{
			echo "<script>history.go(-1);</script>";
		}
		include($file_foot);
		exit;
	}
}

function getTemplates($order = "")
{
	global $db;
	if($order)
		$order = " order by $order ";
	$sql = "select * from Template $order";
	$result = $db->query($sql);
	while($row = $db->fetch_array($result))
	{
		$arrReturn[] = new Template($row);
	}
	return $arrReturn;
}

function sub_str($str, $length = 0, $append=true)
{
    $str = trim($str);
    $strlength = strlen($str);

    if ($length == 0 || $length >= $strlength)
    {
        return $str;
    }
    elseif ($length < 0)
    {
        $length = $strlength + $length;
        if ($length < 0)
        {
            $length = $strlength;
        }
    }

    if (function_exists('mb_substr'))
    {
        $newstr = mb_substr($str, 0, $length, 'UTF-8');
    }
    elseif (function_exists('iconv_substr'))
    {
        $newstr = iconv_substr($str, 0, $length, 'UTF-8');
    }
    else
    {
        $newstr = trim_right(substr($str, 0, $length));
    }

    if ($append && $str != $newstr)
    {
        $newstr .= '...';
    }

    return $newstr;
}

function trim_right($str)
{
    $length = strlen(preg_replace('/[\x00-\x7F]+/', '', $str)) % 3;

    if ($length > 0)
    {
        $str = substr($str, 0, 0 - $length);
    }

    return $str;
}

	// 上传文件，根据指定的文件类型和大小存放在指定的路径中；返回存储的文件名
	function uploadFile($formEl, $saveDir, $allowType, $allowSize)
	{
		$file = $_FILES[$formEl]["tmp_name"];
		$file_name = $_FILES[$formEl]["name"];
		$file_type = $_FILES[$formEl]["type"];
		$file_size = $_FILES[$formEl]["size"];

		if (!$file || $file == "none")
			return "";

		$timeNow = date('U');
		if ($file_type == "image/gif")
			$fileExt = ".gif";
		elseif ($file_type == "image/png")
			$fileExt = ".png";
		elseif ($file_type == "image/jpg" || $file_type == "image/jpeg" || $file_type == "image/pjpeg")
			$fileExt = ".jpg";
		elseif ($file_type == "image/bmp")
			$fileExt = ".bmp";
		else
		{
			$fileExt1 = explode(".", $file_name);
			if (is_array($fileExt1) && count($fileExt1) > 1)
				$fileExt = ".".$fileExt1[count($fileExt1) - 1];
		}
		
		if ($allowType && !strstr($allowType, $fileExt))
		{
			$error = true;
			$errorMessage = "上传的文件格式不正确！请上传 $allowType 格式的文件！";
		}
		
		if (!$error	&& $file_size > 3072000)	// 判断文件大小
		{
			$error = true;
			$errorMessage = "请不要上传大于2M的文件！";
		}
		
		if (!$error)
		{
			$tempDir = $saveDir;
			if (!is_dir($tempDir))
				MakeDir($tempDir);
			
			$destFile = $tempDir."/U".$_SESSION["AID"]."D".date('U').'R'.rand(100,999).$fileExt;
			copy($file, $destFile);
			unlink($file);

			return str_replace($tempDir."/", "", $destFile);
		}
		else
			return "error: $errorMessage";
	}
	//递归建立文件夹
	function MakeDir($DirName)
	{
		$dir = split('[\/\\]',$DirName);
		if(!@mkdir($DirName,0775,true))
		{
			$strDir = "";
			for($i = 0; $i < count($dir); $i++)
			{
				$strDir .= $dir[$i]."/";
				if($strDir != "/")
				{
					if(!is_dir($strDir))
						@mkdir($strDir,0775);
				}
			}
		}
	}

	function strInList($str,$strList)
	{
		$list = explode(",",$strList);
		for($i=0;$i<count($list);$i++)
		{
			if($str == $list[$i])
				return true;
		}
		return false;
	}

	function unzip($file, $savePath)
	{
		
	}
	//$filepath:文件存入其他表的路径 $realpath:文件在服务器上的绝对路径 $info:文件信息，格式(数据库名:表名:主键值)
	function insertFileInfo($filepath, $realpath, $info)
	{
		
	}

	function checkAdmin()
	{
		
	}
	function strInArray($str, $arr)
	{
		if(!is_array($arr))
			return $str == $arr;
		foreach($arr as $val)
		{
			if(strInArray($str, $val))
				return true;
		}
		return false;
	}
	function execSql($sql)
	{
		if(eregi("^zoshow_sql=",$sql))
		{
			$sql = str_replace("zoshow_sql=","",$sql);
			$db = $GLOBALS['zoshow_db'];
		}
		else
		{
			$db = $GLOBALS['db'];
		}
		$arrReturn = array();
		if($result = $db->query($sql))
		{
			while ($row = $db->fetch_array($result))
			{
				$arrReturn[] = $row;
			}
		}
		return $arrReturn;
	}
	// 需要GD支持
	function zoomImage($img_src,$width=0,$height=0,$prefix='', $quality = 0)
	{
		$img_path = IMG_ROOT.'/'.$img_src;
		if($width<=0 && $height<=0)
		{
			return false;
		}
		if(!$img_src)
		{
			return false;
		}
		if(!is_file($img_path))
		{
			return false;
		}
		//
		$gd_ver = gd_version();
		 
		if ($gd_ver == 0)
		{
			return false;
		}
		$surfix = '';
		// 后缀
		if($width > 0)
		{
			$surfix .= '_w'.$width;
		}
		if($height > 0)
		{
			$surfix .= '_h'.$height;
		}

		$org_info = @getimagesize($img_path);
		$img_org = img_resource($img_path, $org_info[2]);
		/* 原始图片以及缩略图的尺寸比例 */
		$scale_org      = $org_info[0] / $org_info[1];
		/* 处理只有缩略图宽和高有一个为0的情况，这时背景和缩略图一样大 */
		if ($width <= 0)
		{
			$width = ceil($height * $scale_org);
		}
		if ($height <= 0)
		{
			$height = ceil($width / $scale_org);
		}
		/* 创建缩略图的标志符 */
		if ($gd_ver == 2)
		{
			$img_thumb  = imagecreatetruecolor($width, $height);
		}
		else
		{
			$img_thumb  = imagecreate($width, $height);
		}
		// 背景处理
		sscanf('ffffff', "%2x%2x%2x", $red, $green, $blue);
		$clr = imagecolorallocate($img_thumb, $red, $green, $blue);
		imagefilledrectangle($img_thumb, 0, 0, $width, $height, $clr);

		/* 将原始图片进行缩放处理 */
		if ($gd_ver == 2)
		{
			imagecopyresampled($img_thumb, $img_org, 0, 0, 0, 0, $width, $height, $org_info[0], $org_info[1]);
		}
		else
		{
			imagecopyresized($img_thumb, $img_org, 0, 0, 0, 0, $width, $height, $org_info[0], $org_info[1]);
		}
		$img_dest_name = explode('.',$img_src);
		$img_dest_name = $img_dest_name[0].$surfix.'.jpg';
		if($quality > 0 && $quality != 75)
		{
			imagejpeg($img_thumb,IMG_ROOT.'/'.$img_dest_name, $quality);
		}
		else
		{
			imagejpeg($img_thumb,IMG_ROOT.'/'.$img_dest_name);
		}
		return $img_dest_name;
	}
	function gd_version()
	{
		static $version = -1;

		if ($version >= 0)
		{
			return $version;
		}

		if (!extension_loaded('gd'))
		{
			$version = 0;
		}
		else
		{
			// 尝试使用gd_info函数
			if (PHP_VERSION >= '4.3')
			{
				if (function_exists('gd_info'))
				{
					$ver_info = gd_info();
					preg_match('/\d/', $ver_info['GD Version'], $match);
					$version = $match[0];
				}
				else
				{
					if (function_exists('imagecreatetruecolor'))
					{
						$version = 2;
					}
					elseif (function_exists('imagecreate'))
					{
						$version = 1;
					}
				}
			}
			else
			{
				if (preg_match('/phpinfo/', ini_get('disable_functions')))
				{
					/* 如果phpinfo被禁用，无法确定gd版本 */
					$version = 1;
				}
				else
				{
					// 使用phpinfo函数
					ob_start();
					phpinfo(8);
					$info = ob_get_contents();
					ob_end_clean();
					$info = stristr($info, 'gd version');
					preg_match('/\d/', $info, $match);
					$version = $match[0];
				}
			}
		}

		return $version;
	}
	// 
	function img_resource($img_file, $mime_type)
	{
		switch ($mime_type)
		{
			case 1:
			case 'image/gif':
				$res = imagecreatefromgif($img_file);
				break;

			case 2:
			case 'image/pjpeg':
			case 'image/jpeg':
				$res = imagecreatefromjpeg($img_file);
				break;

			case 3:
			case 'image/x-png':
			case 'image/png':
				$res = imagecreatefrompng($img_file);
				break;

			default:
				return false;
		}

		return $res;
	}
	if(!function_exists("addslashes_deep"))
	{
		function addslashes_deep($value)
		{
			if (empty($value))
			{
				return $value;
			}
			elseif (is_object($value))
			{
				foreach ($value as $k=>$a)
				{
					$value->$k = addslashes_deep($a);
				}
				return $value;
			}
			else
			{
				return is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value);
			}
		}
	}
	function file_getcsv($input, $delimiter=',', $enclosure='"', $escape='', $charset='utf-8')
	{
		$arr = array();
		if($handle = @fopen($input, "r"))
		{
			while ($data = fgetcsv($handle, 1000000, $delimiter, $enclosure)) 
			{
				foreach ($data as $k=>$v)
				{
					$data[$k] = iconv('gb2312', $charset, $v);
				}
				$arr[] =$data;
			}
			fclose($handle);
		}
		return $arr;
	}
	function MakeDir1($dirurl)
	{
		$dir = explode('/',$dirurl);
		$strDir = "";
		for($i = 0; $i < count($dir); $i++)
		{
			$strDir .= $dir[$i]."/";
			if($strDir != "/")
			{
				if(!@is_dir($strDir))
				{
					@mkdir($strDir,0775);
					@chmod($strDir,0775);
				}
			}
		}
	}
	
	/**************************************
	 * 获取价格
	 * @param array $product_id   当前产品ID
	 * @return array
	 **************************************/
	   function get_price($product_id)
	   {
		   	global $db;
		   	$product_id=intval($product_id);
		   	$sql="SELECT * FROM license WHERE `product_id`=".$product_id;
			$result = $db->query($sql);
			while($item = $db->fetch_array($result))
			{
		   		if($item['license_id'] == 11){
		   			if($item['sub_license_id'] == 0 )
		   			{
		   				if($item['website_display'])
		   				{
		   					$price['curr'] = $item['price'];
		   				}
		   				else 
		   				{
		   					$price['old'] = $item['price'];
		   					$price['unique'] = true;
		   				}
		   			}
		   			else
		   			{
		   				if($item['website_display'])
		   				{
		   					$price['curr'] = $item['price'];
		   				}
		   			}
		   		}
		   	}
		   	if(empty($price['curr'])){
		   		$price['curr'] = $price['old'];
		   		$price['unique'] = true;
		   	}
	   		return $price;
	   }
	   
	 /**************************************
	 * 获取在售的版本
	 * @param array $product_id   产品id
	 * @return array
	 **************************************/
	   function get_sale_version($product_id)
	   {
	   		global $db;
		   	$product_id=intval($product_id);
		   	$sql='SELECT * FROM version WHERE `product_id`='.$product_id.' AND `is_sale`=1 ORDER BY version_name DESC LIMIT 0,1';
		   	$result = $db->query($sql);
			while($item = $db->fetch_array($result))
			{
				$versions=$item;
			}
		   	return $versions;
	   }
	   /**************************************
	 * 获取产品tab下一页链接的名称
	 * @param array $name  tab名称
	 * @return string
	 **************************************/
	   function get_next_name($name,$p_name)
       {
       	
		  switch ($name) {
		  case 'Overview': 
		   $value = 'Explore '.$p_name;
		   break;
		  case "Samples": 
		   $value = 'View '.$p_name.' samples';
		   break;
		  case "Demo": 
		   $value = 'Watch '.$p_name.' demo';
		   break;
		  case "Templates": 
		   $value = 'Watch templates in '.$p_name;
		 
		   break;
		  case "Guide": 
		   $value = 'Read '.$p_name.' user guide';
		   break;
		  case "Tech Spec": 
		   $value = 'View '.$p_name.' tech spec';
		   break;
		  case "Awards": 
		   $value = 'Learn about '.$p_name.' awards';
		   break;
		  case "Comparison": 
		   $value = 'Learn about the comparison chart';
		   break;
		  case "Screenshot": 
			$value = 'Learn about the '.$p_name.' screenshot';
		   break;
		   
		   case "DVD Menu": 
		   $value = 'View '.$p_name.' dvd menu';
		   break;
		   case "Styles": 
		   $value = 'View '.$p_name.' styles';
		   break;
		   
		   }
		  return $value;
        }
     /**************************************
	 * 替换成线上需要的地址根据本页面来替换
	 * @param $web_url   网站地址
	 * @param $replace_url   要替换的地址
	 * @param $type  替换类型
	 * @return string
	 **************************************/   
    
    function  url_replace($web_url = '',$replace_url = '' ,$type = '')
	{
	   $end_url = '';
	   if($type == 'buy_url')
	   {
	      $end_url = str_replace('/store.wondershare.com/httpdocs/','http://store.wondershare.com/shop/',$replace_url); 
		  return $end_url;
	   }
	   elseif($type == 'product_url' )
	   {
	       $replace_url = str_replace('/wondershare.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.com/httpdocs/','',$web_url); 
		   

	   }elseif($type == 'support' )
	   {
	       $replace_url = str_replace('/support.wondershare.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/support.wondershare.com/httpdocs/','',$web_url);
	   }
	   else if($type == 'spotmau')
	   {
	       $replace_url = str_replace('/spotmau.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/spotmau.com/httpdocs/','',$web_url); 
	   }
	   else if($type == 'applemacvideo')
	   {
	       $replace_url = str_replace('/applemacvideo.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/applemacvideo.com/httpdocs/','',$web_url); 
	   }
	   else if($type == 'anypdftools')
	   {
	       $replace_url = str_replace('/resource.anypdftools.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/resource.anypdftools.com/httpdocs/','',$web_url); 
	   }
	   else if($type == 'aimersoft')
	   {
	       $replace_url = str_replace('/aimersoft.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/aimersoft.com/httpdocs/','',$web_url); 
	   }
	   else if($type == 'iskysoft')
	   {
	       $replace_url = str_replace('/iskysoft.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/iskysoft.com/httpdocs/','',$web_url); 
	   }
	   else if($type == 'wondershare.jp')
	   {
	       $replace_url = str_replace('/wondershare.jp/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.jp/httpdocs/','',$web_url); 
	   }
	   else if($type == 'wondershare.de')
	   {
	       $replace_url = str_replace('/wondershare.de/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.de/httpdocs/','',$web_url); 
	   }
	    else if($type == 'wondershare.com.br')
	   {
	       $replace_url = str_replace('/wondershare.com.br/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.com.br/httpdocs/','',$web_url); 
	   }
	    else if($type == 'wondershare.com.mx')
	   {
	       $replace_url = str_replace('/wondershare.com.mx/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.com.mx/httpdocs/','',$web_url); 
	   }
	  else if($type == 'wondershare.com')
	   {
	       $replace_url = str_replace('/wondershare.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.com/httpdocs/','',$web_url); 
	   }
		else if($type == 'wondershare.fr')
	   {
	       $replace_url = str_replace('/wondershare.fr/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.fr/httpdocs/','',$web_url); 
	   }
		else if($type == 'wondershare.es')
	   {
	       $replace_url = str_replace('/wondershare.es/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/wondershare.es/httpdocs/','',$web_url); 
	   }
		else if($type == 'support.iskysoft.com')
	   {
	       $replace_url = str_replace('/support.iskysoft.com/httpdocs/','',$replace_url); 
		   $replace_url = str_replace('index.html','',$replace_url); 
		   $web_url = str_replace('/support.iskysoft.com/httpdocs/','',$web_url); 
	   }
	   
	   
	   if(substr_count($web_url ,'/') == 2)
		{
		  $end_url   =  '../../'.$replace_url   ;
		}
		elseif(substr_count($web_url ,'/') == 1)
		{
		 $end_url  =  '../'.$replace_url   ;
		}
		elseif(substr_count($web_url ,'/') == 0)
		{
		 $end_url  =  $replace_url   ;
		}
	    return $end_url;
		
	}

	
	 /**************************************
	 * 获取价格
	 * @param array $product_id   当前产品ID
	 * @return array
	 **************************************/
	   function get_price_license($product_id,$license_id)
	   {
		   	global $db;
		   	$product_id=intval($product_id);
		   	$license_id=intval($license_id);
		   	$sql="SELECT * FROM license WHERE `product_id`=".$product_id;
			$result = $db->query($sql);
			while($item = $db->fetch_array($result))
			{
		   		if($item['license_id'] == $license_id){
		   			if($item['sub_license_id'] == 0 )
		   			{
		   				if($item['website_display'])
		   				{
		   					$price['curr'] = $item['price'];
		   					$price['cart_url']=$item['cart_url'];
		   					$price['swreg_url']=$item['swreg_url'];
		   				}
		   				else 
		   				{
		   					$price['old'] = $item['price'];
		   					$price['unique'] = true;
		   				}
		   			}
		   			else
		   			{
		   				if($item['website_display'])
		   				{
		   					$price['curr'] = $item['price'];
		   					$price['cart_url']=$item['cart_url'];
		   					$price['swreg_url']=$item['swreg_url'];
		   				}
		   			}
		   		}
		   	}
		   	if(empty($price['curr'])){
		   		$price['curr'] = $price['old'];
		   		$price['unique'] = true;
		   	}
	   		return $price;
	   }
		/**
		 @ get the html url
		 @ by yuantuan
		*/
		function getURL($url){
		   return file_exists($url) ? file_exists($url) : '';
		}   
		
		
		/**
		 @ get the url Dir Level
		 @ by yuantuan
		*/		
		function getDirLevel($url,$split)
		{
			$str = stristr($url,$split);
			$count = count(explode('/',$str))-2;
			$dir = '';
			for($i=0;$i<$count;$i++)
			{
				$dir .='../';
			}
			return $dir;
		}

		/**
		 @ get the google_code of category
		 @ by yuantuan
		*/		
		function getGoodCode($id, $type='')
		{
            global $db;
            if($type=='google_code_article') {
                $sql = "select `ar_cat_id` from `topic_article` where `ar_id`={$id} and `is_delete`=0";
                $categoryId = $db->getOne($sql);
                if($categoryId) {
                    $sql = "select `google_code_article` from `category` where cat_id={$categoryId} and `is_delete`=0";
                    return $db->getOne($sql);
                }
            } else if($type=='google_code_oview') {
                $sql = "select `cat_id` from `won_product` where `id`={$id} and `won_product_delete`=0";
                $categoryId = $db->getOne($sql);
                if($categoryId) {
                    $sql = "select `google_code_oview` from `category` where cat_id={$categoryId} and `is_delete`=0";
                    return $db->getOne($sql);
                }
            }else if($type=='google_code_guide') {
                $sql = "select `cat_id` from `won_product` where `id`={$id} and `won_product_delete`=0";
                $categoryId = $db->getOne($sql);
                if($categoryId) {
                    $sql = "select `google_code_guide` from `category` where cat_id={$categoryId} and `is_delete`=0";
                    return $db->getOne($sql);
                }
            } else if($type=='google_code_buy') {
            	
                $sql = "select `cat_id` from `won_product` where `id`={$id} and `won_product_delete`=0";
                $categoryId = $db->getOne($sql);
                if($categoryId) {
                    $sql = "select `google_code_buy` from `category` where cat_id={$categoryId} and `is_delete`=0";
                    return $db->getOne($sql);
                }
                
            } else if($type=='google_code_install') {
            	
                $sql = "select `cat_id` from `won_product` where `id`= '{$id}' and `won_product_delete`=0";
                $categoryId = $db->getOne($sql);
                if($categoryId) {
                    $sql = "select `google_code_install` from `category` where cat_id= '{$categoryId}' and `is_delete`=0";
                    return $db->getOne($sql);
                }
                
            } else if($type=='google_code_uninstall') {
            	
                $sql = "select `cat_id` from `won_product` where `id`= '{$id}' and `won_product_delete`=0";
             
                $categoryId = $db->getOne($sql);
                if($categoryId) {
                    $sql = "select `google_code_uninstall` from `category` where cat_id= '{$categoryId}' and `is_delete`=0";
               
                    return $db->getOne($sql);
                }
                
            } else if($type=='google_code_register') {
            	
                $sql = "select `cat_id` from `won_product` where `id`= '{$id}' and `won_product_delete`=0";
                $categoryId = $db->getOne($sql);
                if($categoryId) {
                    $sql = "select `google_code_register` from `category` where cat_id= '{$categoryId}' and `is_delete`=0";
                    return $db->getOne($sql);
                }
                
            }
			return '';
		}
		
		/**
		 * 获取IP
		 * @return string
		 * */
		function getIp(){
			if(!empty($_SERVER["HTTP_CLIENT_IP"])){
				$cip = $_SERVER["HTTP_CLIENT_IP"];
			}else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
				$cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
			}else if(!empty($_SERVER["REMOTE_ADDR"])){
				$cip = $_SERVER["REMOTE_ADDR"];
			}else $cip = "";
			preg_match('/[\d\.]{7,15}/', $cip, $cips);
			$cip = $cips[0] ? $cips[0] : 'unknown';
			unset($cips);
			return $cip;
		}
		
		/**
		 * 获取IP
		 * @return string
		 * */
		function getIp2()
		{
		    static $realip = NULL;
		
		    if ($realip !== NULL)
		    {
		        return $realip;
		    }
		    if (isset($_SERVER))
		    {
		        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
		        {
		            $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
		
		            /* 取X-Forwarded-For中第一个非unknown的有效IP字符串 */
		            foreach ($arr AS $ip)
		            {
		                $ip = trim($ip);
		
		                if ($ip != 'unknown')
		                {
		                    $realip = $ip;
		
		                    break;
		                }
		            }
		        }
		        elseif (isset($_SERVER['HTTP_CLIENT_IP']))
		        {
		            $realip = $_SERVER['HTTP_CLIENT_IP'];
		        }
		        else
		        {
		            if (isset($_SERVER['REMOTE_ADDR']))
		            {
		                $realip = $_SERVER['REMOTE_ADDR'];
		            }
		            else
		            {
		                $realip = '0.0.0.0';
		            }
		        }
		    }
		    else
		    {
		        if (getenv('HTTP_X_FORWARDED_FOR'))
		        {
		            $realip = getenv('HTTP_X_FORWARDED_FOR');
		        }
		        elseif (getenv('HTTP_CLIENT_IP'))
		        {
		            $realip = getenv('HTTP_CLIENT_IP');
		        }
		        else
		        {
		            $realip = getenv('REMOTE_ADDR');
		        }
		    }
		
		    preg_match("/[\d\.]{7,15}/", $realip, $onlineip);
		    $realip = !empty($onlineip[0]) ? $onlineip[0] : '0.0.0.0';
		
		    return $realip;
		}
  /**
  * 日志入库
  *
  * @param   $array     $log_name 提交表单数组
  * @param   string     $log_cat  日志分类
  * @param   string     $log_desc 日志描述
  * @param   string     $log_web  网 站
  * @param   string     $log_table 表
  * @param   string     $log_user 用户
  */  
  function add_log($log_name,$log_cat,$log_desc,$log_web,$log_table,$log_user)
  {
      global $db;
	  $log_user = $log_user ? $log_user : $_SESSION['AName'];
	  $sql ="
	  INSERT INTO `log` 
	  (
	    `log_name`,`log_cat`,`log_desc`,`log_web`,`log_table`,`log_user`,`log_add_time`
	  ) 
	  VALUES (
	  '$log_name','$log_cat','$log_desc','$log_web','$log_table','$log_user',now()
	  ) ";
	  $db->query($sql);
  }	
  
  
  /**
 * 删除$dir文件夹中index.html和数字.html
 * @param string $dir 要删除其中html的文件夹
 * @return boolean
 * */
  function del_dir_file( $dir ){

	if( substr( $dir, -1, 1 ) != '/' ) $dir .=  '/';
 	if( is_dir( $dir ) ){
 		$dir_arr = glob( $dir.'*' );
 		foreach( $dir_arr as $v ){
 			if( !strpos( $v, '.' )) continue;
 			$m = end( explode('/', $v ) );
			$n = explode('.',$m);
 			if( $m == 'index.html' || ((int)$n[0] && $n[1] == 'html') ) unlink( $v );
 		}
 		return true;
 	}else{
 		return false;
 	}
 }
     //用于新模板
 /**
 * 把数组 转化成GET
 * @param array $val 要转化的数组
 * @return boolean
 * */
  function arr_to_gets( $val ){
   	if(is_array($val))
   	{
   		foreach ($val AS $key => $value)
   		{
   			if(is_array($_GET[$key] ))
   			{
   				arr_to_gets($_GET[$key]);
   			}else
   			{
   				$_GET[$key] = $value;
   			}
   		}
   	}
   	return true;
 }
 
 	  /**************************************
	 * 把同步过来的faq和在线帮助的内容的图片替换成绝对地址
	 * @param $contents   需要替换的内容
	 * @return string
	 **************************************/   
	function support_replace_img($contents, $webDomain = 'i.wondershare.com')
	{
		$contents = preg_replace('/src(\s*?)=(\s*?)"\.\.\/\.\.\/upload_images\//si','src="http://'.$webDomain.'/upload_images/',$contents);
		$contents  = preg_replace('/src(\s*?)=(\s*?)"\/upload_images\//si','src="http://'.$webDomain.'/upload_images/',$contents);
		$contents  = preg_replace('/src(\s*?)=(\s*?)"upload_images\//si','src="http://'.$webDomain.'/upload_images/',$contents);
		return $contents;
	}
	
	  /**************************************
	 * support网站登录html代码
	 * @return string
	 **************************************/   
	function support_login($web_fage = 1 )
	{
		$login_html = $login_js = '';
		if ($web_fage ==  1)  {//代表为wondershare网站
			
			$login_html = '
			<div class="showcont fl" style="width:65px;" id = "login" > 
			<a href="javascript:void(0)" class="login">Login</a>
			<div class="showlist loginbg">
			<p class="dd">Login to view your order detail and manage your support ticket.
			</p>
			<form method="post" name="login" action="http://i.wondershare.com/index.php?module=default&submod=customer&method=login" id="login_form">
			<table width="92%" border="0" align="center" cellpadding="0" cellspacing="5">
			<tr>
			<td width="75" align="right">Email:</td>
			<td><div class="input_bg">
			<input id="email" name="email" dataType="Email" msg="Invalid e-mail." />
			</div></td>
			</tr>
			<tr>
			<td align="right">Password:</td>
			<td><div class="input_bg">
			<input type="password" name="email_pass" dataType="Require" msg="Invalid password."  />
			</div></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td style="padding:5px 0 0 0;"><input name="" value="" type="submit" 
			style="background:url(\'http://support.wondershare.com/style/style_img/btn_sign.png\');width:100px;height:25px; border:none;cursor:pointer;" onclick="top_form=1;" /></td>
			</tr>
			</table>
			</form>
			<p class="link"><a href="http://i.wondershare.com/index.php?module=default&submod=customer&method=reset_passwd">Forgot Password?</a> | 
			<a href="http://i.wondershare.com/index.php?module=default&submod=customer&method=register">Sign Up</a></p>
			<p class="tips">Tips: If you have bought a Wondershare Product, your account info is enclosed in the email.</p>
			</div>';
			
			 $login_js = '<script type="text/javascript" src="http://support.wondershare.com/script/checkform.js"></script> 
		     <script type="text/javascript" src="http://support.wondershare.com/script/global.js"></script> 
		     <script type="text/javascript" src="http://support.wondershare.com/script/jquery.ws.js"></script>
			<script type="text/javascript">
			var remind_obj;
			var top_form = 0;
			//note 重设错误提示位置
			function __setEMPPos( obj, left, top ){
				remind_obj = obj;
				if( top_form == 1 ){
					$(obj).css("left",(left - 550)+"px");
					$(obj).css("top",(top - 120)+"px");
				}else{
					$(obj).css("left",(left + 380)+"px");
					$(obj).css("top",(top + 36)+"px");
				}
			}
			</script>';
		} elseif ($web_fage ==  8)  {//代表为iskysoft网站
			
			$login_html = '
			<div id="login" style="width: 65px;" class="showcont fl"> 
			<a class="login" href="javascript:void(0)">Login</a>
			<div class="showlist loginbg" >
			<p class="dd">Login to view your order detail and manage your support ticket.
			</p>
			<form id="login_form" action="http://i.iskysoft.com/index.php?module=default&amp;submod=customer&amp;method=login" name="login" method="post">
			<table align="center" cellspacing="5" cellpadding="0" border="0" width="92%">
			<tbody><tr>
			<td align="right" width="75">Email:</td>
			<td><div class="input_bg">
			<input msg="Invalid e-mail." type="text" datatype="Email" name="email" id="email">
			</div></td>
			</tr>
			<tr>
			<td align="right">Password:</td>
			<td><div class="input_bg">
			<input type="password" msg="Invalid password." datatype="Require" name="email_pass">
			</div></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td style="padding:5px 0 0 0;"><input type="submit" onclick="top_form=1;" style="background:url(\'http://support.iskysoft.com/images/btn_sign.png\');width:100px;height:25px; border:none;cursor:pointer;" value="" name=""></td>
			</tr>
			</tbody></table>
			</form>
			<p class="link mtb10"><a href="http://i.iskysoft.com/index.php?module=default&amp;submod=customer&amp;method=reset_passwd">Forgot Password?</a> | 
			<a href="http://i.iskysoft.com/index.php?module=default&amp;submod=customer&amp;method=register">Sign Up</a></p>
			<p class="tips">Tips: If you have bought an iSkysoft Product, your account info is enclosed in the email.</p>
			</div>';
			
			 $login_js = '<script type="text/javascript" src="http://support.iskysoft.com/js/checkform.js"></script> 
		     <script type="text/javascript" src="http://support.iskysoft.com/js/global.js"></script> 
		     <script type="text/javascript" src="http://support.iskysoft.com/js/jquery.ws.js"></script>
			<script type="text/javascript">
			var remind_obj;
			var top_form = 0;
			//note 重设错误提示位置
			function __setEMPPos( obj, left, top ){
				remind_obj = obj;
				if( top_form == 1 ){
							$(obj).css("left",(left - 1050)+"px");
							$(obj).css("top",(top - 154)+"px");
				}else{
					$(obj).css("left",(left + 380)+"px");
					$(obj).css("top",(top + 36)+"px");
				}
			}
			</script>';
		} elseif ($web_fage ==  2)  {//代表为aimersoft网站
			
			$login_html = '
			<div class="showcont" id="login"> 
			<a href="javascript:void(0)" class="login">Login</a>
			<div class="showlist loginbg">
			<p class="dd">Login to view your order detail and manage your support ticket.</p>
			<form method="post" name="login" action="http://i.aimersoft.com/index.php?module=default&submod=customer&method=login" id="login_form">
			<table width="92%" border="0" align="center" cellpadding="3" cellspacing="0">
			<tr>
			<td width="75" align="right">Email:</td>
			<td><div class="input_bg">
			<input id="email" name="email" dataType="Email" msg="Invalid e-mail." />
			</div></td>
			</tr>
			<tr>
			<td align="right">Password:</td>
			<td><div class="input_bg">
			<input type="password" name="email_pass" dataType="Require" msg="Invalid password." />
			</div></td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			<td><input name="" value="" type="submit" class="submit_btn"	onclick="top_form=1;" /></td>
			</tr>
			</table>
			</form>
			<p class="link"><a href="http://i.aimersoft.com/index.php?module=default&submod=customer&method=reset_passwd">Forgot Password?</a> | 
			<a href="http://i.aimersoft.com/index.php?module=default&submod=customer&method=register">Sign Up</a></p>
			<p class="tips">Tips: If you have bought a Aimersoft Product, your account info is enclosed in the email.</p>
			</div>
   			</div>';
			
			 $login_js = '<script type="text/javascript" src="http://support.aimersoft.com/scripts/checkform.js"></script> 
		     <script type="text/javascript" src="http://support.aimersoft.com/scripts/global.js"></script> 
		     <script type="text/javascript" src="http://support.aimersoft.com/scripts/jquery.ws.js"></script>
			<script type="text/javascript">
			var remind_obj;
			var top_form = 0;
			//note 重设错误提示位置
			function __setEMPPos( obj, left, top ){
				remind_obj = obj;
				if( top_form == 1 ){
							$(obj).css("left",(left - 1030)+"px");
							$(obj).css("top",(top - 145)+"px");
				}else{
					$(obj).css("left",(left + 380)+"px");
					$(obj).css("top",(top + 36)+"px");
				}
			}
			</script>';
		}
	 	return array('login_html'=>$login_html,'login_js'=>$login_js);
	}
//用于新模板
 /**************************************
 * 把相对地址替换成绝对地址
 * @param $web_url   网站地址
 * @param $replace_url   要替换的地址
 * @param $type  替换类型
 * @return string
 **************************************/   
function  url_new_replace($replace_url = '', $type = '', $support_domain = 'support.wondershare.com') {
	
	$web_url = '';
   if ($type == 'support' ) {

        $replace_url = str_replace(array('/'.$support_domain.'/httpdocs/','index.html'),
        							array('http://'.$support_domain.'/',''), $replace_url); 
		

   } else if($type == 'spotmau') {
   	   $replace_url = str_replace(array('/spotmau.com/httpdocs/','index.html'),
       array('http://www.spotmau.com/',''),$replace_url); 


   }  else if($type == 'applemacvideo') {
   		$replace_url = str_replace(array('/applemacvideo.com/httpdocs/','index.html'),
       array('http://www.applemacvideo.com/',''),$replace_url); 

   } else if($type == 'anypdftools') {
   		$replace_url = str_replace(array('/resource.anypdftools.com/httpdocs/','index.html'),
       array('http://resource.anypdftools.com/',''),$replace_url); 

   } else if($type == 'aimersoft')  {
   		$replace_url = str_replace(array('/aimersoft.com/httpdocs/','index.html'),
       array('http://www.aimersoft.com/',''),$replace_url); 
     
   } else if($type == 'iskysoft') {
   		$replace_url = str_replace(array('/iskysoft.com/httpdocs/','index.html'),
       array('http://www.iskysoft.com/',''), $replace_url); 
   } else if($type == 'wondershare.jp') {
   		$replace_url = str_replace(array('/wondershare.jp/httpdocs/','index.html'),
       array('http://www.wondershare.jp/',''),$replace_url); 
   } else if($type == 'wondershare.de') {
   		$replace_url = str_replace(array('/wondershare.de/httpdocs/','index.html'),
       array('http://www.wondershare.de/',''),$replace_url); 
   
   } else if($type == 'wondershare.com.br') {
   		$replace_url = str_replace(array('/wondershare.com.br/httpdocs/','index.html'),
       array('http://www.wondershare.com.br/',''),$replace_url); 

   } else if($type == 'wondershare.com.mx') {
   		$replace_url = str_replace(array('/wondershare.com.mx/httpdocs/','index.html'),
       array('http://www.wondershare.com.mx/',''),$replace_url); 
   } else if($type == 'wondershare.com') {
		$replace_url = str_replace(array('/wondershare.com/httpdocs/','index.html'),
       array('http://www.wondershare.com/',''),$replace_url); 

   } else if($type == 'wondershare.fr') {
  	 	$replace_url = str_replace(array('/wondershare.fr/httpdocs/','index.html'),
       array('http://www.wondershare.fr/',''),$replace_url); 
   } else if($type == 'wondershare.es') {
   		$replace_url = str_replace(array('/wondershare.es/httpdocs/','index.html'),
       array('http://www.wondershare.es/',''),$replace_url); 
   } else if($type == 'daniusoft') {
   		$replace_url = str_replace(array('/daniusoft.com/httpdocs/', 'index.html'),
       array('http://www.daniusoft.com/', ''),$replace_url); 
       
   } else if($type == 'iskysoft.jp') {
   		$replace_url = str_replace(array('/iskysoft.jp/httpdocs/', 'index.html'),
       array('http://www.iskysoft.jp/', ''),$replace_url);    
   }

    return $replace_url;
	
}

 /**************************************
 * 把数据库中存在的url替换成网站上的地址带域名
 * @param $template_url   要替换的地址
 * @return string
 **************************************/   
function  urlToWebUrl($template_url = '') {
	
	$web_url = '';
	$web_name = '';
	if (substr_count($template_url, '/wondershare.com/httpdocs') > 0 ) {
		$web_url = str_replace('/wondershare.com/httpdocs', 'http://www.wondershare.com', $template_url);
		$web_name = 'wondershare.com';
		
	} else if (substr_count($template_url, '/store.wondershare.com/httpdocs') > 0 ) {
		$web_url = str_replace('/store.wondershare.com/httpdocs', 'http://store.wondershare.com/shop', $template_url);
		$web_name = 'store.wondershare.com';
		
	} else if (substr_count($template_url, '/spotmau.com/httpdocs') > 0 ) {
		$web_url = str_replace('/spotmau.com/httpdocs', 'http://www.spotmau.com', $template_url);
		$web_name = 'spotmau.com';
		
	} else if (substr_count($template_url, '/applemacvideo.com/httpdocs') > 0 ) {
		$web_url = str_replace('/applemacvideo.com/httpdocs', 'http://www.applemacvideo.com', $template_url);
		$web_name = 'applemacvideo.com';
		
	} else if (substr_count($template_url, '/anypdftools.com/httpdocs') > 0 ) {
		$web_url = str_replace('/anypdftools.com/httpdocs', 'http://www.anypdftools.com', $template_url);
		$web_name = 'anypdftools.com';
		
	} else if (substr_count($template_url, '/aimersoft.com/httpdocs') > 0 ) {
		$web_url = str_replace('/aimersoft.com/httpdocs', 'http://www.aimersoft.com', $template_url);
		$web_name = 'aimersoft.com';
		
	} else if (substr_count($template_url, '/wondershare.de/httpdocs') > 0 ) {
		$web_url = str_replace('/wondershare.de/httpdocs', 'http://www.wondershare.de', $template_url);
		$web_name = 'wondershare.de';
		
	} else if (substr_count($template_url, '/wondershare.jp/httpdocs') > 0 ) {
		$web_url = str_replace('/wondershare.jp/httpdocs', 'http://www.wondershare.jp', $template_url);
		$web_name = 'wondershare.jp';
		
	} else if (substr_count($template_url, '/iskysoft.com/httpdocs') > 0 ) {
		$web_url = str_replace('/iskysoft.com/httpdocs', 'http://www.iskysoft.com', $template_url);
		$web_name = 'iskysoft.com';
		
	} else if (substr_count($template_url, '/support.wondershare.com/httpdocs') > 0 ) {
		$web_url = str_replace('/support.wondershare.com/httpdocs', 'http://support.wondershare.com', $template_url);
		$web_name = 'support.wondershare.com';
		
	} else if (substr_count($template_url, '/m.wondershare.com/httpdocs') > 0 ) {
		$web_url = str_replace('/m.wondershare.com/httpdocs', 'http://m.wondershare.com', $template_url);
		$web_name = 'm.wondershare.com';
		
	} else if (substr_count($template_url, '/wondershare.fr/httpdocs') > 0 ) {
		$web_url = str_replace('/wondershare.fr/httpdocs', 'http://www.wondershare.fr', $template_url);
		$web_name = 'wondershare.fr';
		
	} else if (substr_count($template_url, '/wondershare.com.mx/httpdocs') > 0 ) {
		$web_url = str_replace('/wondershare.com.mx/httpdocs', 'http://www.wondershare.com.mx', $template_url);
		$web_name = 'wondershare.com.mx';
		
	} else if (substr_count($template_url, '/wondershare.es/httpdocs') > 0 ) {
		$web_url = str_replace('/wondershare.es/httpdocs', 'http://www.wondershare.es', $template_url);
		$web_name = 'wondershare.es';
		
	}else if (substr_count($template_url, '/wondershare.com.br/httpdocs') > 0 ) {
		$web_url = str_replace('/wondershare.com.br/httpdocs', 'http://www.wondershare.com.br', $template_url);
		$web_name = 'wondershare.com.br';
		
	} else if (substr_count($template_url, '/support.iskysoft.com/httpdocs') > 0 ) {
		$web_url = str_replace('/support.iskysoft.com/httpdocs', 'http://support.iskysoft.com', $template_url);
		$web_name = 'support.iskysoft.com';
		
	}else if (substr_count($template_url, '/resource.anypdftools.com/httpdocs') > 0 ) {
		$web_url = str_replace('/resource.anypdftools.com/httpdocs', 'http://resource.anypdftools.com', $template_url);
		$web_name = 'resource.anypdftools.com';
	}

    return array('web_url' => $web_url, 'web_name' => $web_name);
	
}

/**************************************
 * 插入记录
 * @param $file_dir   cdn同步要发布的文件夹，
 * @param $url   要写入cdn同步文件的url
 * @return string
 **************************************/   
function  cdnInsertFile($file_dir, $url) {
	
	$cdn_file = $file_dir.'/urls.txt';
	if (!is_dir($file_dir)) {
		MakeDir1($file_dir);
	}
	
	$url = $url."\n";
	
	if (file_exists($cdn_file)) {
		
		$contents = file_get_contents($cdn_file);
		//判断url是否存在文件中
		if (substr_count($contents, $url) == 0) {
			file_put_contents($cdn_file, $url, FILE_APPEND);
		}
		
	} else {
		file_put_contents($cdn_file, $url, FILE_APPEND);
	}
	
}

/**************************************
 * 得到产品下载跳转链接
 * @param $web_type   网站类型
 * @param $id   产品id(won_product表中的id)
 * @return string
 **************************************/   
function  getProductDownloadJumpUrl($web_type, $id) {
	
	global $db;
	$url = ''; 
	switch ($web_type) {
		
		case 'wondershare': 
			
			$sql = "SELECT url FROM Table_194 WHERE Field_22053 = '{$id}' LIMIT 1 ";
			$url = $db->getOne($sql);
			if (!empty($url)) {
			 	$url =  str_replace(array('/wondershare.com/httpdocs', 'index.html'), array('http://www.wondershare.com', ''), $url);
			} 
			
		break;
		
	}
	
	return $url;
	
}
/**
 * 取得远程文件的大小
 * @param string $url 远程文件的绝对路径
 * @return 空或文件大小，单位为M
 * */
function getFileSize($url) {
	$f = get_headers( $url, 1 );	
	if( $f ){
		foreach( $f['Content-Length'] as $v){
			$size = max($size, $v );
		}
		$size = sprintf('%0.2f', $size / 1000000);
	}else{
		$size = null;
	}
	return $size;
}

/**************************************
 * 获取价格
 * @param array $product_id   当前产品ID
 * @param array $sub_license_id  
 * @return array
 **************************************/
   function get_price_info($product_id, $sub_license_id = 0, $is_user_license_id = 0) {
   	
	   	global $db;
	   	$product_id = intval($product_id);
	   	
	   	if ($is_user_license_id) {
	   		
		   	$sql = "SELECT  swreg_url, sub_license_id  
		   			FROM license 
		   			WHERE product_id = {$product_id} AND license_id = 11 AND sub_license_id = {$sub_license_id}
		   			LIMIT 1";
			$rows = $db->getOneRs($sql);
			if ($rows['sub_license_id'] != 0 || empty($rows)) {
				
				$sql = "SELECT price 
			   			FROM license 
			   			WHERE product_id = {$product_id} AND license_id = 11 AND sub_license_id = 0
			   			LIMIT 1";
				$price['old'] =  $db->getOne($sql);;
			} else {
				$price['old'] = $rows['price'];
			}
			
			$price['swreg_url'] = $rows['swreg_url'];
			
	   	} else {
	  	 	$sql = "SELECT price, website_display, swreg_url, sub_license_id  
		   			FROM license 
		   			WHERE product_id = {$product_id} AND license_id = 11 AND sub_license_id = 0
		   			LIMIT 1";
			$rows = $db->getOneRs($sql);
			$price['old'] = $rows['price'];
			if ($rows['website_display'] == 0) {
				
				$sql = "SELECT price, swreg_url  
			   			FROM license 
			   			WHERE product_id = {$product_id} AND license_id = 11 AND website_display = 1
			   			LIMIT 1";
				$rows = $db->getOneRs($sql);
				$price['swreg_url'] = $rows['swreg_url'];
				$price['curr'] = $rows['price'];
				
				
			} else {
				$price['swreg_url'] = $rows['swreg_url'];
				$price['curr'] = $rows['price'];
			}
	   	}
	   	
	   	return $price;
   }

?>
